const initialState = {
    logininfo:{

    },
    arr:[]

}

export default (state = initialState, { type, payload,ind }) => {
  switch (type) {

  case 'logininfo':
    let newlogininfo = JSON.parse(JSON.stringify(state.logininfo))
     newlogininfo = payload
    return { ...state, logininfo:newlogininfo }
  case "getlist":
    let newarr = JSON.parse(JSON.stringify(state.arr))
    newarr = payload
    return {
      ...state,
      arr:newarr
    }
  case "collection" :
    let newcollectionarr = JSON.parse(JSON.stringify(state.arr))
    newcollectionarr[payload].children[ind].flag = !newcollectionarr[payload].children[ind].flag 
    return {
      ...state,
      arr:newcollectionarr
    }
  default:
    return state
  }
}
